<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@page import="java.util.List"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css" />
		<script src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
		<script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
	</head>

	<body>

		<form class="layui-form" action="" id="m_updateForm">
		<div class="layui-form-item">
			<input type="hidden" value="${id}" name="id">
				<div class="layui-input-inline" style="width: 48%;">
					<select name="collegeId" lay-verify="required" lay-filter="filter">
						<option value="${major.collegeId}">${major.sName}</option>
						<c:forEach items="${ac}" var="college">
							<option value="${college.collegeId}">${college.sName}</option>
						</c:forEach>
					</select>
				</div>
				
			</div>
			
			<div class="layui-form-item">
				
				<div class="layui-input-inline" style="width: 48%;">
					<input type="text" name="cName" required lay-verify="required" placeholder="请输入专业名"
						autocomplete="off" class="layui-input" value="${major.cName}">
				</div>
				<div class="layui-input-inline" style="width: 48%;">
					<input type="text" name="majorId" required lay-verify="required" placeholder="请输入专业id"
						autocomplete="off" class="layui-input" value ="${major.majorId}">
				</div>
			</div>				
			<button type="reset" class="layui-btn layui-btn-primary" style="width: 40%;">重置</button>
		</form>
		<button class="layui-btn" lay-submit lay-filter="formDemo" style="width: 40%;" onclick="insert(${major.majorId})">立即提交</button>
		

		<script>
		function insert(){
			var params = $("form").serialize();
			console.info(params);
			$.ajax({
				url: "major?m=majorUpdate",
				data: params,
				type: "post",
				success: function(code){
					if(code == '1'){
						alert("更改成功");
					} else {
						alert("更改失败");
					}
					//延迟关闭
					setTimeout(closeLayer(), 500);
				}
			});
		}
		
		function closeLayer(){
			//关闭弹出层
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
			//刷新父页面
			window.parent.location.reload();
		}
		</script>	



	</body>
</html>